package com.cys.dm.rest.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cys.dm.dao.item.DmItemTypeDao;
import com.cys.dm.entity.item.DmItemType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class DmItemTypeService {

    @Resource
    private DmItemTypeDao dmItemTypeDao;


    @PostMapping(path = "/findByParent/{parent}")
    public List<DmItemType> dmItemTypeList(@PathVariable("parent")Long parent){
        QueryWrapper<DmItemType> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent",parent);
        return dmItemTypeDao.selectList(queryWrapper);
    }

    @PostMapping(path = "/findByLinAsNav")
    public List<DmItemType> findBylinAsNav(){
        QueryWrapper<DmItemType> queryWrapper = new QueryWrapper<>();
        queryWrapper.and(wq->wq.isNotNull("aliasName"));
        queryWrapper.eq("level",1L);
        return dmItemTypeDao.selectList(queryWrapper);
    }

    @PostMapping(path = "/postFloorData")
    public List<DmItemType> postFloorData(){
        QueryWrapper<DmItemType> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("level",1);
        return dmItemTypeDao.selectList(queryWrapper);
    }

}
